﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace L05
{
    class Program
    {
        static void Main(string[] args)
        {
            Car car = new Car(5,30);
            Truck truck = new Truck(200,30);

            car.Run(10);
            truck.Run(10);

            Console.ReadKey();

        }

        public abstract class Vehicle
        {
            public float V { get; set; }//以包含V的定义

            public Vehicle (float v)
            {
                V = v;
            }

            public virtual void Run(float d)
            {
                Console.WriteLine("行驶{0}公里用时{1}",d,d/V );
            }
        }

        public class Car:Vehicle 
        {
            public int Passengers { get ; set ; }

            public Car(int passengers,float v):base (v)
            {
                Passengers = passengers;
            }
        }

        public class Truck:Vehicle
        {
            public float Load { get; set ; }

            public Truck(float load, float v):base (v)
            {
                Load = load;
            }

            public override void Run(float d)
            {
                //base.Run(d);
                Console.WriteLine("当车辆载重量为{0}时，行驶{1}公里所需的时间为{2}",Load ,d,(1+Load /100)*d/V);
            }


        }
    }
}
